package com.emr.web.controller.emr;


import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.emr.common.annotation.Log;
import com.emr.common.enums.BusinessType;
import com.emr.module.domain.Qiyongyuan;
import com.emr.module.service.IQiyongyuanService;
import com.emr.web.core.base.BaseController;
import com.emr.framework.web.page.TableDataInfo;
import com.emr.common.base.AjaxResult;

/**
 * 预案组启用 信息操作处理
 * 
 * @author emr
 * @date 2019-03-01
 */
@Controller
@RequestMapping("/module/qiyongyuan")
public class QiyongyuanController extends BaseController
{
    private String prefix = "module/qiyongyuan";
	
	@Autowired
	private IQiyongyuanService qiyongyuanService;
	
	@RequiresPermissions("module:qiyongyuan:view")
	@GetMapping()
	public String qiyongyuan()
	{
	    return prefix + "/qiyongyuan";
	}
	
	/**
	 * 查询预案组启用列表
	 */
	@RequiresPermissions("module:qiyongyuan:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Qiyongyuan qiyongyuan)
	{
		startPage();
        List<Qiyongyuan> list = qiyongyuanService.selectQiyongyuanList(qiyongyuan);
		return getDataTable(list);
	}
	
	/**
	 * 新增预案组启用
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存预案组启用
	 */
	@RequiresPermissions("module:qiyongyuan:add")
	@Log(title = "预案组启用", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Qiyongyuan qiyongyuan)
	{		
		return toAjax(qiyongyuanService.insertQiyongyuan(qiyongyuan));
	}

	/**
	 * 修改预案组启用
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Integer id, ModelMap mmap)
	{
		Qiyongyuan qiyongyuan = qiyongyuanService.selectQiyongyuanById(id);
		mmap.put("qiyongyuan", qiyongyuan);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存预案组启用
	 */
	@RequiresPermissions("module:qiyongyuan:edit")
	@Log(title = "预案组启用", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Qiyongyuan qiyongyuan)
	{		
		return toAjax(qiyongyuanService.updateQiyongyuan(qiyongyuan));
	}
	
	/**
	 * 删除预案组启用
	 */
	@RequiresPermissions("module:qiyongyuan:remove")
	@Log(title = "预案组启用", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(qiyongyuanService.deleteQiyongyuanByIds(ids));
	}
	
}
